import Mock from 'mockjs';
const Random = Mock.Random;

Mock.mock('/api/user','get',{
    code: 200,
    message: "操作成功",
    data: {
        id:1,
        name:'@cname',
        gender:Random.pick(['男','女']),
    }
})

const users =Mock.mock({
    'list|1-10':[{
        'id|+1':1,
        name:'@cname',
        gender:Random.pick(['男','女']),
    }]
})
Mock.mock('/api/user/list','get',{
    code: 200,
    message: "操作成功",
    data: users.list
})
Mock.mock('/\/api\/user\/getUserById','get',(req,res)=>{
    const id=req.url.match(/id=(\d+)/)[1];
    const user=users.list.find(user=>user.id==id)
    return {
        code: 200,
    message: "操作成功",
    data: user
    }
})